<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <base href="<%=basePath %>">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="js/layui/css/layui.css"  media="all">
    <style>
        .layui-table th{
            font-size: 18px;
            background-color: transparent !important;
        }
        .layui-table {
            background-color: transparent !important;
        }
    </style>
</head>
<body>
<div style=" margin-top: 20px">

    <div style="margin-left: 10px;margin-left:550px;float: left">
         <input class="layui-input" style="width: 200px;" type="text" name="keyword"  placeholder="搜索项目" id="demoReload" autocomplete="off">
    </div>
    <div  style="padding-left: 10px; float: left">
        <button class="layui-btn"  data-type="reload" id="sousuo">搜索</button>
    </div >
    <div style="width: 858px">
    <table  class="layui-table" id="test1" lay-filter="demo"></table>
    </div>
</div>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-sm" style="font-size:15px"  lay-event="onLine">上线</a>
</script>

<script src="js/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['table' ,'laypage'], function(){
        var table = layui.table;
        var $ = layui.$;
        table.render({
            elem: '#test1'
            ,height: 500
            ,size:'lg'
            ,url: 'item/recovery?type='+${type} //数据接口  请求自动拼接参数page=1&limit=10
            , limit: 10 //每页显示条数
            ,cols: [[ //表头
                // {type:'checkbox', fixed: 'left'}
                {field: 'id', title: 'ID', width:80,style:"font-size:18px", sort: true,align:'center'}
                ,{field: 'title', title: '项目名称',style:"font-size:18px" ,width:200}
                ,{field: 'userNicename', title: '发起人',style:"font-size:18px", align:'center',  width:150}
                ,{field: 'updatetime', title: '下线时间',style:"font-size:18px", align:'center', width:200}
                ,{field: 'right', title: '操作', width:220, style:"font-size:18px",align:'center', toolbar: '#barDemo'}
            ]]
            ,page:true//开启分页
        });
        $('.layui-table-page').css('margin-left', '250px');// 分页右对齐
        //  监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
           if(obj.event === 'onLine'){
                layer.confirm("确定上线项目？",function (index) {
                    $.ajax({
                        url:"item/updItemStatus?",
                        data:{"status":"1","id":data.id},
                        dataType:"json",
                        method:"get",
                        success:function (res) {
                            if(res.statusCode==300){
                                layer.alert("上线失败")
                            }
                        }
                    })
                    layer.close(index);
                    table.reload("test1",{
                        page: {
                            curr: 1  //重载后显示页码
                        }
                    });
                })
            }
        });


        //搜索按钮事件
        $('#sousuo').on('click',function () {
            var inputVal = $('.layui-input').val();//获取input输入内容
            //表格重载
            table.reload('test1', {
                where: {
                    title : inputVal  //携带参数 或变更参数
                }
                ,page: {
                    curr: 1  //重载后显示页码
                }
            })
        });
    })

</script>

</body>
</html>